package org.example.thread;

public class Demo2 {

    public static void main(String[] args) {
        Thread thread = Thread.currentThread();
        System.out.println("thread.getId() = " + thread.getId());
        System.out.println("thread.getName() = " + thread.getName());
        System.out.println("thread.getPriority() = " + thread.getPriority());

        new Thread(()->{
            Thread thread1 = Thread.currentThread();
            System.out.println("---thread.getId() = " + thread1.getId());
            System.out.println("---thread.getName() = " + thread1.getName());
            System.out.println("---thread.getPriority() = " + thread1.getPriority());
        }).start();

        Thread thread2 = new Thread(() -> {
            Thread thread1 = Thread.currentThread();
            System.out.println("---===thread.getId() = " + thread1.getId());
            System.out.println("---===thread.getName() = " + thread1.getName());
            System.out.println("---===thread.getPriority() = " + thread1.getPriority());
            System.out.println("---=== " + thread1.getName() + "休眠 15 秒");
            try {
                Thread.sleep(15000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }, "yc");
        thread2.setName("ly");
        thread2.setPriority(10);
        // 守护线程 精灵线程
        thread2.setDaemon(true);
        thread2.start();

        System.out.println("主线程执行结束");
    }
}
